/*
* Copyright 2016 Yonyou Auto Information Technology（Shanghai） Co., Ltd. All Rights Reserved.
*
* This software is published under the terms of the YONYOU Software
* License version 1.0, a copy of which has been included with this
* distribution in the LICENSE.txt file.
*
* @Project Name : marketing-dealerApp-open-api
*
* @File name : DealerAppHomePageController.java
*
* @Author : WangHuicheng
*
* @Date : 2016年11月21日
*
----------------------------------------------------------------------------------
*     Date       Who       Version     Comments
* 1. 2016年11月21日    WangHuicheng    1.0
*
*
*
*
----------------------------------------------------------------------------------
*/
	
package com.yonyou.gmmc.dealerApp.api.controller;

import java.util.HashMap;
import java.util.Map;

import javax.validation.Valid;

import org.apache.log4j.Logger;
import org.marketing.common.constants.ResultMsgConstants;
import org.marketing.common.dto.maintain.MaintainFrecordDto;
import org.marketing.common.dto.search.DealerAppSearchDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.yonyou.gmmc.dealerApp.api.constant.DealerAppConstant;
import com.yonyou.gmmc.dealerApp.api.service.CallMaintainService;

/**
 * 询价模块新库中没有，暂时不理
 * */

/**
* DealerApp用户养修预约信息
* @author WangHuicheng

* @date 2016年11月21日
*/
@RestController
@RequestMapping(value = DealerAppConstant.BASE_PATH+"/maintain")
public class DealerAppMaintainController {
    private Logger  logger = Logger.getLogger(DealerAppMaintainController.class);

    
    @Autowired
    CallMaintainService callMaintainServiceInterface;
    
    @RequestMapping(value="/getMaintainInfoList",method=RequestMethod.POST,produces="application/json;charset=UTF-8")
    @ResponseBody
    public Map<String,Object>getMaintainInfoList(@RequestBody DealerAppSearchDto dealerAppSearchDto){
        Map<String,Object> result = new HashMap<String,Object>();
        try{
            result = callMaintainServiceInterface.getMaintainInfoList(dealerAppSearchDto);
        } catch(Exception e){
            this.logger.info("错误详细：",e);
            result.put(ResultMsgConstants.RESULT_CODE, 0);
            result.put(ResultMsgConstants.ERR_MSG, e.getMessage());
        }
        return result;
    }
    
    /**
    *
    * @author WangHuicheng
    * 保存试驾预约跟进记录
    * @date 2016年11月21日
    * @param testDrivingAmDto
    * @return
    * @throws Exception
    */
    @RequestMapping(value = "/saveFollowRecords", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
    public @ResponseBody Map<String, Object> saveTestDrivingAppointFrecord(@RequestBody @Valid MaintainFrecordDto maintainFrecordDto) {
        Map<String,Object> result = new HashMap<String,Object>();
        try{
            result = callMaintainServiceInterface.saveTestDrivingAppointFrecord(maintainFrecordDto);
        } catch(Exception e){
            this.logger.info("错误详细：",e);
            result.put(ResultMsgConstants.RESULT_CODE, 0);
            result.put(ResultMsgConstants.ERR_MSG, e.getMessage());
        }
        return result;
        
    }

    

    /**
     * 
    * 更新养修预约
    * @author WangHuicheng
    * @date 2016年11月28日
    * @param maintainFrecordDto
    * @return
     */
    @RequestMapping(value = "/updateMaintainStatus",method = RequestMethod.POST,produces = "application/json;charset=UTF-8")
    public @ResponseBody Map<String,Object> updateMaintainStatus(@RequestBody @Valid MaintainFrecordDto maintainFrecordDto) {
        Map<String,Object> result = new HashMap<String,Object>();
        try{
            result = callMaintainServiceInterface.updateMaintainStatus(maintainFrecordDto);
        } catch(Exception e){
            this.logger.info("错误详细：",e);
            result.put(ResultMsgConstants.RESULT_CODE, 0);
            result.put(ResultMsgConstants.ERR_MSG, e.getMessage());
        }
        return result;
    }
}
